import { clamp } from "../../../core/utils/utils";
import { AiInterface } from "./interface";

export class BasicAi extends AiInterface{
  constructor(root){
    super(root);
  }

  runAction(){
    let actionUnit = this.root.battleMgr.actionUnit;
    let skills = actionUnit.people.getSkills(false);

    setTimeout(() => {
      if(skills.length > 0){
        skills[0].aiRun();
        this.root.battleMgr.runAction();
      } else {
        this.root.battleMgr.actionUnit.showMsg('我什么也干不了。')
        this.root.battleMgr.endAction();
      }
    }, clamp(Math.random() * 2, 1, 2) * 1000);
  }
}